#include "stm32f10x.h"                  // Device header
#include "Delay.h"
#include "OLED.h"
#include "Serial.h"
#include "Ds18b20.h"
#include "Buzzer.h"
#include "Motor.h"

uint8_t ucbuf[17];
float temp_data = 0.0;
float temp_data1 = 0.0;

void TEMP_Value_Conversion()
{
    temp_data1 = DS18B20_Get_Temp();
	  temp_data1 = DS18B20_Get_Temp() / 10.0;
    sprintf((char*)ucbuf, "%4.2f", temp_data1); 
    OLED_ShowString(1, 1, "Temp:");
    OLED_ShowString(1, 6, (uint8_t*)ucbuf);
    OLED_ShowChar(1, 11, 'C');
}

int main(void)
{
  
    OLED_Init();
    DS18B20_Init();
    Serial_Init();
    Buzzer_Init();
    Motor_Init();  
    

    while (1)
    {
        
        TEMP_Value_Conversion();

      
        if (temp_data1 >= 28.0)
        {
            Buzzer_ON();       
            Motor_SetSpeed(80); 
        }
        else
        {
            Buzzer_OFF();       
            Motor_SetSpeed(0);  
        }

        Delay_ms(500);
    }
}